package com.hbuzzs.elasticsearch.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description 通过@Document注解可以声明一个文档，指定其所在的索引库和type
 * @Author zhangzhishun
 * @Date 2020/11/28-9:31
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "index_test", type = "type_test")
public class TestBean implements Serializable {

    private Long id;

    @Field(type = FieldType.Keyword, store = true)
    private String name;

    @Field(type = FieldType.Keyword, store = true)
    private Integer age;

    @Field(type = FieldType.Keyword, store = true)
    private String sex;

    @Field(type = FieldType.Keyword, store = true)
    private String desc;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date insertTime;

}
